package com.brainhealth.common.utils;

import java.util.regex.Pattern;

/**
 * @author wll
 */
public class NumberUtils {
    public static boolean isNumeric(String str){
        for (int i = str.length();--i>=0;){
            if (!Character.isDigit(str.charAt(i))){
                return false;
            }
        }
        return true;
    }

    public static Long toLong(Object object){
        if (null==object){
            return null;
        }
        return Long.parseLong(String.valueOf(object));
    }

    public static boolean isPositiveInteger(String str)
    {
       return Pattern.matches("\\d+", str);
    }

    public static boolean isNumInRange(Integer min, Integer max, Integer num) {
        if (null == min || null == max || null == num) {
            return false;
        }
        return num >= min && num <= max;
    }
}
